package com.baichang.taoshunda.controller.mobile.delivery;

import com.baichang.framework.controller.BaseMobileController;
import com.baichang.framework.excelption.ServiceException;
import com.baichang.taoshunda.controller.ControllerConstants;
import com.baichang.taoshunda.dao.ScoreGoodsDao;
import com.baichang.taoshunda.entity.Html;
import com.baichang.taoshunda.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * Created by Dylan on 2017/6/5.
 */
@Controller
@RequestMapping(ControllerConstants.WEBVIEW)
public class WebVideMController extends BaseMobileController {


    @Autowired
    private PushService pushService;
    @Autowired
    private ParamsService paramsService;
    @Autowired
    private BusinessService businessService;
    @Autowired
    private WaiterService waiterService;
    @Autowired
    private ScoreGoodsDao scoreGoodsDao;
    @Autowired
    private HtmlService htmlService;

    /**
     * 关于我们
     *
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping("/aboutUs")
    public String aboutUs(HttpServletRequest request, HttpServletResponse response, Model model) {
        Map content = paramsService.getParamsValue(20, 12);
        model.addAttribute("content", content.get("remark"));
        return "taoshunda/aboutUs";
    }

    /**
     * 用户协议
     *
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping("/userAgreement")
    public String userAgreement(HttpServletRequest request, HttpServletResponse response, Model model) throws ServiceException {
        Html content = htmlService.queryById(3);
        model.addAttribute("content", content.getValue());
        return "taoshunda/aboutUs";
    }

    /**
     * 配送端隐私
     *
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping("/deliveryPrivacy")
    public String deliveryPrivacy(HttpServletRequest request, HttpServletResponse response, Model model) throws ServiceException {
        Html content = htmlService.queryById(13);
        model.addAttribute("content", content.getValue());
        return "taoshunda/aboutUs";
    }

    /**
     * 消息详情
     *
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping("/pushDetail")
    public String pushDetail(HttpServletRequest request, HttpServletResponse response, Model model) {
        Integer pushId = ServletRequestUtils.getIntParameter(request, "pushId", 0);
        Map<String, Object> map = pushService.getPushDetail(pushId);
        model.addAttribute("map", map);
        return "taoshunda/pushDetail";
    }

    /**
     * 商家分享
     *
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping("/bussDetail")
    public String bussDetail(HttpServletRequest request, HttpServletResponse response, Model model) throws ServiceException {
        Integer busId = ServletRequestUtils.getIntParameter(request, "busId", 0);
        Map<String, Object> map = businessService.getBussDetails(busId);
        model.addAttribute("map", map);
        return "taoshunda/bussDetail";
    }

    /**
     * 本地服务分享
     *
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping("/waiterService")
    public String waiterService(HttpServletRequest request, HttpServletResponse response, Model model) {
        Integer id = ServletRequestUtils.getIntParameter(request, "id", 0);
        Map<String, Object> map = waiterService.getWaiterByid(id);
        model.addAttribute("map", map);
        return "taoshunda/waiterService";
    }

//    /**
//     * 商品分享
//     *
//     * @param request
//     * @param response
//     * @param model
//     * @return
//     */
//    @RequestMapping("/goodsDetail")
//    public String goodsDetail(HttpServletRequest request, HttpServletResponse response, Model model) {
//        Integer id = ServletRequestUtils.getIntParameter(request, "id", 0);
//        Map<String, Object> map = goodsService.getShareGoodsById(id);
//        model.addAttribute("map", map);
//        return "taoshunda/goodsDetail";
//    }

    /**
     * 积分商品分享
     *
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping("/scoreGoodsDetail")
    public String scoreGoodsDetail(HttpServletRequest request, HttpServletResponse response, Model model) {
        Integer id = ServletRequestUtils.getIntParameter(request, "id", 0);
        Map<String, Object> map = scoreGoodsDao.getScoreGoodsById(id);
        model.addAttribute("map", map);
        return "taoshunda/scoreGoodsDetail";
    }

    /**
     * 淘友圈
     *
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping("/friends")
    public String friends(HttpServletRequest request, HttpServletResponse response, Model model) {

        return "taoshunda/friends";
    }


}
